package com.jy.api.service.impl;

import com.jy.api.dao.NoticeDao;
import com.jy.api.domain.Notice;
import com.jy.api.service.NoticeSrvice;
import com.jy.api.signUpReq.web.WebNoticeSignUpReq;
import com.jy.api.util.Contens;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * Created by lihu on 2018/3/3.
 */
@Service
public class NoticeSrviceImpl implements NoticeSrvice {

    @Autowired
    NoticeDao noticeDao;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Override
    @Transactional
    public void addNotice(WebNoticeSignUpReq signUpReq) {
        Notice notice = new Notice(signUpReq);
        noticeDao.save(notice);

        stringRedisTemplate.opsForValue().set(Contens.SYNCH_NOTIC_TIME.
                replace("STOREID", signUpReq.getStoreId()), new Date().getTime() + "");
    }
}
